Method of creating drive component object and realizing device drive program multiplicity on basis of category

ABSTRACT

A method of creating drive component object and realizing device drive program multiplicity on basis of category, in which the drive component class is defined and realized at first, then the component customer program creates drive object with category intellectual pointer. In present invention, the operation system selects automatically the corresponding component based on specified component kind by customer specification and realizes further a multi-mode access to drive program from application program. In present invention, certain overheads for efficiency are needed to be added only in the dynamic binding in course of drive object creating; once drive object is created, the operation system would returns the common interface realized by drive object back to the application program and application program may invoke directly the particular drive object method, it has no extra efficiency overhead and realizes a multi-mode access to drive program from application program.

FIELD OF THE INVENTION

[0001] The present invention relates to A method of creating drive component object and realizing device drive program multiplicity on basis of category, especially relates to a component creating method in which the operation system selects automatically the corresponding component based on specified component kind by customer specification and realizes further a multi-mode access to drive program from application program, it belongs to the computer technology field.

BACKGROUND OF THE INVENTION

[0002] In operation system, true hardware drive program always execute the I/O access against to certain specified hardware device and provide the upper application with the access interface of this specified device. However, to the users of drive program, in most cases, they don't care about what device is being utilized, but care about only if existing any usable device of this type in system. For example, the application program utilizing printer care about only if there is any usable printer in device but don't care about whether the printer is a parallel one, a serial one, or network one, not to mention the printer type or trademark. In view of this, the practice is not reasonable that application program which is utilizing printer specifies directly the printer drive program to be used.

[0003] To solve this problem, the practice in traditional operation system is to divide drive program into layers, refer to FIG. 1, printer drive program usually is divided into 3 layers: i.e. hardware I/O layer 3, print drive layer 2 and application interface layer 1. In application interface layer 1, the operation system realizes a pseudo-print drive program with the aim of providing a standard printer interface for upper layer application program, so the application program may utilizes it without care about the particular printer type. The lower layer print drive program registers oneself to the pseudo-drive program of fictitious printer in installation, and the fictitious printer driver could transfer the print request of upper layer application to the particular print drive program to execute corresponding print order.

[0004] This property which obtains various function characteristics in according to the various entity object (drive program) cited by interface through abstract interface (application interface layer 1) is referred to as multi-mode in the component-oriented (or object-oriented) technology.

[0005] The isolation problem between application program and particular hardware could be resolved satisfactorily by the multi-mode characteristic. However, owing to the fact that there is no true component object model (short in COM) in core of the traditional operation system to support this characteristic, there are following 2 problems in this model: i.e. 1. there is no common utility and it is needed to realize a pseudo-drive program of upper layer application-oriented for every kind of device; 2. the needing for interface layer transfer brings about a extra efficiency overhead and unnecessary data copy in some times.

[0006] In COM, all the component uses the class identification (short in CLSID) as a unique identifier of component class, each CLSID corresponds to a component realization.

[0007] It is considered by COM specification that the binary multi-mode is realized once abstracting fictitious interface out. However the practice is not like this. In time that component customer terminal utilizes component, it needs still to specify the CLSID of component server to create component object, and specifying the CLSID means specifying the component realization.

[0008] Take the above printer model as example: suppose that the print drive programs are in component-wise and they all realize the “printer common interface”; if it is required that the application program specifies CLSID in time of drive object creating, the print drive program kind is specified, and this in fact couldn't reach still the target of transparency from device and driving to application program.

[0009] So abstracting the interface out merely realizes a multi-mode in component method invoking but the multi-mode of component creation don't be realized. The utilization of a component is always gone through 3 courses of creating, invoking and withering away, the multi-mode in component application may be realized only if realizing the multi-mode of component creation.

BRIEF DESCRIPTION OF THE INVENTON

[0010] The basic purpose of present invention is provide a method of creating drive component object and realizing device drive program multiplicity on basis of category, in which the operation system selects automatically the corresponding component based on specified component kind by customer specification and realizes further a multi-mode access to drive program from application program.

[0011] The purpose of present invention is realized as follows:

[0012] A method of creating drive component object and realizing device drive program multiplicity on basis of category, it includes at least the followings:

[0013] Step 1: Define and realize drive component category;

[0014] Step 2: The component customer program creates drive object based on the drive component category.

[0015] Said realize method includes further: setup the default class identifier (CLSID) of this category in component category.

[0016] The CLSID setup method in said component category is: register the component category and component class belonged to it, and register the last one to the CLSID in component category as the default CLSID of this component category.

[0017] The CLSID setup method in said component category may be:

[0018] Step 31; Read in the component register information in system component category register file;

[0019] Step 32: Read out the component metadata packeted in the corresponding dynamic link library file resource section;

[0020] Step 33: Check if new category is defined in component metadata, otherwise execute Step 35;

[0021] Step 34: Add the new category information including drive component category identifier into the category register information;

[0022] Step 35: Check if the component class belonged to the component category in category register information exists in metadata, and execute Step 37 if no existing;

[0023] Step 36: Add the component class information including drive component category identifier to the corresponding component category and regard this component class as a default component class in this category;

[0024] Step 37: Wright the revised category register information back to the system category register file.

[0025] The CLSID setup method in said component category may be: in case of there are more than 1 component class corresponding component category in dynamic link library file defining component category, the last component class belonged to this category is utilized as a default class, otherwise return a failure information.

[0026] Said Step 1 includes in particular:

[0027] Step 11: Define the component class by inheriting the defined component category;

[0028] Step 12: Realize the component class according to component function requirement;

[0029] Step 13: Compile component program and register automatically the component category.

[0030] In which Step 13 includes in particular:

[0031] Step 131: Compile the component program and generate component dynamic link library file;

[0032] Step 132: Register the defined component category and component class included in category.

[0033] In present invention, before defining and realizing drive component class, include further the category of defining drive utilizing the component description language.

[0034] one or more interfaces may be defined for said drive component class.

[0035] Said Step 2 includes in particular the following creation steps:

[0036] Step 21: Specify the drive component category identifier (CATID) of which the drive object is to be created;

[0037] Step 22; Fetch the default class identifier CLSID of this category;

[0038] Step 23: Judge if this CLSID belong to drive program category, execute Step 24 if yes, or create the general component object with CLSID and execute Step 26 if not;

[0039] Step 24: Create the particular drive object with CLSID;

[0040] Step 25: Inquire out the common interface in category from drive object (QueryInterface, a standard method stipulated by COM specification and used for inquiring if it supports the specified interface from component object);

[0041] Step 26: Return back the common interface of the category.

[0042] The present invention has following advantages:

[0043] 1) It don't need to realize a pseudo-drive to act as a common entry for each kind of drive, but all drives belonging to this category may realize the common interface so long as the common interface of this drive category is defined;

[0044] 2) In present invention, certain overheads in efficiency are needed to be added only in the dynamic binding in course of drive object creating; once drive object is created, the operation system would returns the common interface realized by drive object back to the application program and application program may invoke directly the particular drive object, it has no extra efficiency overhead and realizes a multi-mode access to drive program from application program.

BRIEF DESCRIPTION OF THE APPENDED DRAWINGS

[0045]FIG. 1 is an illustrative view showing the traditional drive model.

[0046]FIG. 2 is an illustrative view showing drive model of component category based in the present invention.

[0047]FIG. 3 is a flowchart showing drive program creating based on component category in the present invention.

DETAILED DESCRIPTION OF THE INVENTION

[0048] Next, a further description will be made as to the present invention with the Figures and concrete embodiment:

[0049] For purpose of present invention, a designed component category includes a group of common interfaces, if a certain drive component class is going to belong to this category, it must inherit this category and realize all the interfaces included in this category. The component category itself has no realization code, so the component category may be called abstract class or hyper class.

[0050] All the component class inheriting the component category realize all the interfaces included in component category, and this is the technology base of component category is acting as a common entry of all the component class in category.

[0051] Refer to FIG. 2, which is a model illustrative view, taking print drive as example and showing that the component-wise drive program is created with component category.

[0052] The application program creates the component driving by specifying print drive category, operation system creates the defaulted print drive in category for the application program and returns the print drive interface back to application program, the application program may invoke directly this interface method of print drive object to execute print operation.

[0053] For example, in application layer, the application program requests operation system to create print drive by specifying printer category, e.g. HP LaserJet (a type of printer).

[0054] The operation system find out the defaulted component in the category (HP LaserJet in figure) according to HP LaserJet category identifier specified by application program and creates drive component object.

[0055] In case of object creating is succeed, operation system returns directly the common interface back to application program. In this way, the interfacing method invoked by application program is one that revoking directly the HP LaserJet drive object, and no need the involvement and transfer of operation system any more.

[0056] Refer to FIG. 3, the concrete realization method is:

[0057] Define the drive category first, for example, the drive category defined with component description language in component description language (CDL in short) file of component object model (easy component object Model, ezCOM for short), e.g. define a print drive category titled as “CatPrinter) and describe with particular CDL language as follows: [uuid(02aff0b1-a887-4da7-bf2e-626af6165a56)] category CatPrinter{ interface Iprinter; }

[0058] in which,

[0059] [uuid(02aff0b1-a887-4da7-bf2e-626af6165a56)] is same of current COM specification and means attribute information of this component;

[0060] category CatPrinter defines a printer category CatPrinter;

[0061] interface Iprinter defines a printer interface Iprinter.

[0062] The print drive category CatPrinter includes a printer interface IPrinter (Refer to the relative COM specification for conception of interface and defining form). In present invention, 1 or more interfaces may be defined for a category.

[0063] Defining the Component Class

[0064] If a certain drive component class is going to belong to the print drive category CatPrinter, it must inherits this print drive category CatPrinter, for example: the defining form of HP LaserJet 6Lprint drive component is described with particular CDL language as bellow: [uuid(9defd903-6443-4eed-b4e4-a3020b448cb5 ),driver] class CHPLaserJet6L: CatPrinter{ interface ILaserJet6L; }

[0065] In which,

[0066] [uuid(9defd903-6443-4eed-b4e4-a3020b448cb5), driver] is same as the current COM specification and indicates attribute information of the component;

[0067] class CHPLaserJet6L: CatPrinter defines a printer class CHPLaserJet6L,

[0068] interface ILaserJet6L means: define a printer interface ILaserJet6L.

[0069] In which, the definition itself of class CHPLaserJet6L includes printer interface ILaserJet6L, at same time it inherits the print drive category CatPrinter and includes also the printer interface IPrinter in print drive category CatPrinter.

[0070] The driver attribute announce before component class indicates that the class CHPLaserJet6L is a drive program. So CHPLaserJet6L has to realizes another implicit system interface: i.e. drive interface Idriver; this is because that the drive program itself is a category also, all the component class defined by driver attribute in operation system are belonged to drive program category CatDriver, and drive interface IDriver is included in the drive program category CatDriver.

[0071] In the embodiment, drive program category CatDriver includes drive interface IDriver. All the drive component class in the embodiment are inherited from the drive program category CatDriver; Among them, drive program category CatDriver is defined as below: [uuid(0000112d-0000-0000-C000-000000000066)] category CatDriver{ interface IDriver; }

[0072] In which,

[0073] [uuid(0000112d-0000-0000-C000-000000000066)] is same as the current COM specification and indicates attribute information of the component;

[0074] category CatDriver defines a drive device category CatDriver;

[0075] interface Idriver defines a drive device interface Idriver;

[0076] The drive device category Idriver includes a drive device interface Idriver. In present invention, 1 or more interfaces may be defined for a category.

[0077] Realize Component Class

[0078] The drive component category and component class files are compiled and defined with CDL compiler of ezCOM, and the skeleton of component source program is created. The skeleton includes all the interfacing methods of component class, and the component realization operator needs to fill the corresponding realization codes according to component function. Take Cprinter as a example, all the methods in interfaces of IPrinterr, ILaserJet6L and IDriver must be realized.

[0079] Compile the component program and register automatically the component category

[0080] After realizing the code, it needs to compile the component program and generate the dynamic link library file of component. The component category CatPrinter may be added automatically to the category register file “category.cfg”, and the class CHP LaserJet69 is added to the category catPrinter and component category catDriver.

[0081] Repeat the above process, more corresponding drive component class may be defined and realized.

[0082] After the compiling and generation of drive component program, the functions provided by drive program may be utilized through programming the component customer application program. The component customer program could creates the drive object with the intellectual pointer of category, e.g. creates the following codes of print drive object with category catPrinter described by C++ language: #import<printer.dll> ...... CatPrinterRef catPrinterRef; hr= catPrinterRef.Instantiate0; if (FAILED(hr)){ ...... } ......

[0083] Creating the Drive Object by Customer Program

[0084] The realization process of creating drive object with category by driving the component customer program is as bellow:

[0085] 1) Specify the drive component category identifier (CATID) to create the drive object;

[0086] 2) Fetch the default CLSID of this category;

[0087] 3) Judge if this CLSID belong to drive program category (CatDriver);

[0088] 4) Create the particular drive object with CLSID;

[0089] 5) Inquire out the common interface in category from drive object.

[0090] 6) Return back common interface of the category;

[0091] After obtaining the above common interface by component customer, these functions of common interface may be invoked.

[0092] The present invention includes also the setup method of default class identifier (CLSID) in component category and the concrete setup may be any one of the following:

[0093] In time of compiler tool compiling the component program, it could register automatically the component category and component class belonged to it, and register the last one to the CLSID in component category as the default CLSID of this component category.

[0094] Register the Default Class Identifier in Component Category with Special Tool.

[0095] After compiling of dynamic link library (DLL) file which generates component program, the compiler tool would invoke it automatically and register the component.

[0096] In case of no register file, the dynamic link library file defining component category may be used. In case of more than 1 component class belonging to the category in the file, the first component class belonged to this category is utilized as a default class, otherwise return a failure.

[0097] While the present invention has been particularly shown and described with references to preferred embodiments thereof, it is clearly understood that the same is by way of illustration and example only and is not to be taken by way of limitation, it will be understood by those skilled in the art that various variations, alterations, and modifications in form and details may be made therein without departing from the spirit and scope of the invention as defined by the claims and it intended to be encompassed in the scope of the present invention. 

We claim:
 1. A method of creating drive component object and realizing device drive program multiplicity on basis of category, characterized in that: it includes at least the followings: Step 1: Define and realize drive component category; Step 2: The component customer program creates drive object based on the drive component category.
 2. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 1, characterized in that: said realize method includes further: setup the default class identifier (CLSID) of this category in component category.
 3. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 2, characterized in that: the CLSID setup method in said component category is: register the component category and component class belonged to it, and register the last one to the CLSID in component category as the default CLSID of this component category.
 4. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 2, characterized in that: the CLSID setup method in said component category is: Step 31; Read in the component register information in system component category register file; Step 32: Read out the component metadata packeted in the corresponding dynamic link library file resource section; Step 33: Check if new category is defined in component metadata, otherwise execute Step 35; Step 34: Add the new category information including drive component category identifier into the category register information; Step 35: Check if the component class belonged to the component category in category register information exists in metadata, and execute Step 37 if no existing; Step 36: Add the component class information including drive component category identifier to the corresponding component category and regard this component class as a default component class in this category; Step 37: Wright the revised category register information back to the system category register file.
 5. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 2, characterized in that: the CLSID setup method in said component category is: in case of there are more than 1 component class corresponding component category in dynamic link library file defining component category, the last component class belonged to this category is utilized as a default class, otherwise return a failure information.
 6. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 2, characterized in that: Step 1 includes in particular: Step 11: Define the component class by inheriting the defined component category; Step 12: Realize the component class according to component function requirement; Step 13: Compile component program and register automatically the component category.
 7. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 6, characterized in that: Step 13 includes in particular: Step 131: Compile the component program and generate component dynamic link library file; Step 132: Register the defined component category and component class included in category.
 8. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 6, characterized in that: before defining and realizing drive component class, include further the category of defining drive utilizing the component description language.
 9. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 6, characterized in that: 1 or more interfaces may be defined for said drive component class.
 10. A method of creating drive component object and realizing device drive program multiplicity on basis of category according to Claim 1, characterized in that: Step 2 includes in particular: Step 21: Specify the drive component category identifier (CATID) of which the drive object is to be created; Step 22; Fetch the default class identifier CLSID of this category; Step 23: Judge if this CLSID belong to drive program category, execute Step 24 if yes, or create the general component object with CLSID and execute Step 26 if not; Step 24: Create the particular drive object with CLSID; Step 25: Inquire out the common interface in category from drive object (QueryInterface, a standard method stipulated by COM specification and used for inquiring if it supports the specified interface from component object). Step 26: Return back the common interface of the category. 